import tkinter as tk
from tkinter import *
import time
root=tk.Tk()
root.title("计算器")
frm=Frame(root,bg='white')
frm.pack()
display=StringVar()
e=Entry(frm,textvariable=display)
e.grid(row=0,column=0,sticky=N,columnspan=3,rowspan=2)

def jia():
    e.insert(INSERT,'+')
def jian():
    e.insert(INSERT,'-')
def cheng():
    e.insert(INSERT,'*')
def chu():
    e.insert(INSERT,'/')
def dengyu():
    e.insert(INSERT,'=')

Button(frm,text='7',width=5,bg='white',command=lambda:e.insert(INSERT,'7')).grid(row=2,column=0,sticky=N)
Button(frm,text='8',width=5,bg='white',command=lambda:e.insert(INSERT,'8')).grid(row=2,column=1,sticky=N)
Button(frm,text='9',width=5,bg='white',command=lambda:e.insert(INSERT,'9')).grid(row=2,column=2,sticky=N)
Button(frm,text='+',width=5,bg='white',command=jia).grid(row=2,column=3,sticky=N)
Button(frm,text='4',width=5,bg='white',command=lambda:e.insert(INSERT,'4')).grid(row=3,column=0,sticky=N)
Button(frm,text='5',width=5,bg='white',command=lambda:e.insert(INSERT,'5')).grid(row=3,column=1,sticky=N)
Button(frm,text='6',width=5,bg='white',command=lambda:e.insert(INSERT,'6')).grid(row=3,column=2,sticky=N)
Button(frm,text='-',width=5,bg='white',command=jian).grid(row=3,column=3,sticky=N)
Button(frm,text='1',width=5,bg='white',command=lambda:e.insert(INSERT,'1')).grid(row=4,column=0,sticky=N)
Button(frm,text='2',width=5,bg='white',command=lambda:e.insert(INSERT,'2')).grid(row=4,column=1,sticky=N)
Button(frm,text='3',width=5,bg='white',command=lambda:e.insert(INSERT,'3')).grid(row=4,column=2,sticky=N)
Button(frm,text='*',width=5,bg='white',command=cheng).grid(row=4,column=3,sticky=N)
Button(frm,text='CE',width=5,bg='white',command=lambda:e.insert(INSERT,'CE')).grid(row=5,column=0,sticky=N)
Button(frm,text='0',width=5,bg='white',command=lambda:e.insert(INSERT,'0')).grid(row=5,column=1,sticky=N)
Button(frm,text='.',width=5,bg='white',command=lambda:e.insert(INSERT,'.')).grid(row=5,column=2,sticky=N)
Button(frm,text='/',width=5,bg='white',command=chu).grid(row=5,column=3,sticky=N)
root.mainloop